const { DataTypes } = require('sequelize');
// const sequelize = require('@/db/seq');
const sequelize = require("@/db/seq");

const MomentLike = sequelize.define('moment_like', {
  id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true },
  moment_id: { type: DataTypes.INTEGER, allowNull: false },
  user_id: { type: DataTypes.INTEGER, allowNull: false },
}, { freezeTableName: true });

// MomentLike.sync({ alter: true });
MomentLike.associate = (models) => {
  MomentLike.belongsTo(models.moment, { foreignKey: 'moment_id', as: 'likedMoment' });
  MomentLike.belongsTo(models.blog_user, { foreignKey: 'user_id', as: 'liker' });
};
module.exports = MomentLike;